package com.example.kliven.because.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.kliven.because.R;
import com.example.kliven.because.bean.DiscoverBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Kliven on 16/1/7.
 */
public class DiscoverAdapter extends BaseAdapter {

    private List<DiscoverBean> discoverBeans;
    private Context context;

    public DiscoverAdapter(Context context, List<DiscoverBean> discoverBeans) {
        this.context = context;
        this.discoverBeans = discoverBeans;
    }

    @Override
    public int getCount() {
        return discoverBeans.size();
    }

    @Override
    public Object getItem(int i) {
        return discoverBeans;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        MyViewHodler hodler;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.item_discover_list, viewGroup, false);
            hodler = new MyViewHodler(view);
            view.setTag(hodler);
        } else {
            hodler = (MyViewHodler) view.getTag();
        }
        hodler.property_list.setText(discoverBeans.get(i).getProperty_list());
        return view;
    }

    class MyViewHodler {
        TextView property_list;

        public MyViewHodler(View view) {
            property_list = (TextView) view.findViewById(R.id.property_list);
        }
    }
}
